package cn.zmwh.portal.modules.index.pojo.entity;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author dmzmwh
 * @since 2024-08-26
 */
@Getter
@Setter
@TableName("tl_user")
@ApiModel(value = "TlUser对象", description = "")
public class TlUser implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("手机号")
    private String mobile;

    @ApiModelProperty("来源")
    private String origin;

    @ApiModelProperty("邮箱")
    private String email;

    @ApiModelProperty("性别")
    private Integer sex;

    @ApiModelProperty("头像")
    private String avatar;

    @ApiModelProperty("昵称")
    private String nick;

    @ApiModelProperty("座右铭")
    private String motto;

    @ApiModelProperty("用户限制")
    private Integer enabled = 1;

    @ApiModelProperty("限制描述")
    private String detail;

    @ApiModelProperty("邀请人")
    private Long inviteTlId;

    @ApiModelProperty("创建时间")
    private Date createTime;


    /**
     * 获取用户名，优先取手机号
     *
     * @return
     */
    public String getUserName() {
        if (StrUtil.isNotEmpty(mobile)) {
            return mobile;
        }
        return email;
    }
}
